<template>
  <div class="app-container">
    <el-card class="operate-container" shadow="never">
      <i class="el-icon-tickets"></i>
      <span>数据列表</span>
      <el-button style="float: right" @click="handleBack()" type="primary" size="small">返回上一页</el-button>
    </el-card>
    <div class="table-container">
      <el-table
        ref="bannerTable"
        :data="list"
        style="width: 100%;"
        @selection-change="handleSelectionChange"
        v-loading="listLoading"
        border
      >
        <el-table-column type="selection" width="60" align="center"></el-table-column>
        <el-table-column label="编号" width="120" align="center">
          <template slot-scope="scope">{{scope.row.id}}</template>
        </el-table-column>
        <el-table-column label="跟踪人" width="250" align="center">
          <template slot-scope="scope">{{scope.row.trackName}}</template>
        </el-table-column>
        <el-table-column label="跟踪方式" align="center">
          <template slot-scope="scope">{{scope.row.trackWay}}</template>
        </el-table-column>
        <el-table-column label="跟踪内容" align="center">
          <template slot-scope="scope">{{scope.row.remarks}}</template>
        </el-table-column>
        <el-table-column label="图片1" width="250" align="center">
          <template slot-scope="scope">
            <img style="height: 80px" :src="scope.row.images[0]" />
          </template>
        </el-table-column>
        <el-table-column label="图片2" width="250" align="center">
          <template slot-scope="scope">
            <img style="height: 80px" :src="scope.row.images[1]" />
          </template>
        </el-table-column>
        <el-table-column label="图片3" width="250" align="center">
          <template slot-scope="scope">
            <img style="height: 80px" :src="scope.row.images[2]" />
          </template>
        </el-table-column>
        <el-table-column label="跟踪时间" align="center">
          <template slot-scope="scope">{{scope.row.trackTime | formatTime}}</template>
        </el-table-column>
        
      </el-table>
      </el-table>
    </div>
    <div class="pagination-container">
      <el-pagination
        background
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        layout="total, sizes,prev, pager, next,jumper"
        :page-size="listQuery.pageSize"
        :page-sizes="[20]"
        :current-page.sync="listQuery.pageNum"
        :total="total"
      ></el-pagination>
    </div>
  </div>
</template>
<script>
import { fetchList } from "@/api/ums/customerTrack";
import { formatDate } from "@/utils/date";
const defaultListQuery = {
  pageNum: 1,
  pageSize: 20
};
export default {
  name: "bannerList",
  data() {
    return {
      listQuery: Object.assign({}, defaultListQuery),
      list: null,
      total: null,
      listLoading: false,
      multipleSelection: []
    };
  },
  created() {
    this.getList();
  },
  filters: {
    formatTime(time) {
      if (time == null || time === "") {
        return "N/A";
      }
      let date = new Date(time);
      return formatDate(date, "yyyy-MM-dd");
    },
    formatStatus(status) {
      if (status==1) {
        return "锁定在回收站";
      }else {
        return "正常"
      }
    }
  },
  methods: {
    handleSearchList() {
      this.listQuery.pageNum = 1;
      this.getList();
    },
    
    handleSelectionChange(val) {
      this.multipleSelection = val;
    },
    handleSizeChange(val) {
      this.listQuery.pageNum = 1;
      this.listQuery.pageSize = val;
      this.getList();
    },
    handleCurrentChange(val) {
      this.listQuery.pageNum = val;
      this.getList();
    },
    handleDelete(index, row) {
      this.$confirm("确认恢复该客户?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(() => {
        updateCustomer(row.id).then(response => {
          this.$message({
            message: "恢复成功",
            type: "success",
            duration: 1000
          });
          this.getList();
        });
      });
    },
    handleAdd() {
      this.$router.push({ path: "/drivermanage/addCoach" });
    },
    handleBack(index, row) {
      console.log('coachId='+this.$route.query.coachId)
      this.$router.push({
        path: "/drivermanage/customerList",
        query: { id: this.$route.query.coachId }
      });
    },
    getList() {
      this.listLoading = true;
      this.listQuery.customerId = this.$route.query.id;
      fetchList(this.listQuery).then(response => {
        this.listLoading = false;
        this.list = response.data.records;
        this.total = response.data.total;
      });
    }
  }
};
</script>
<style scoped>
.input-width {
  width: 203px;
}
</style>


